home *** CD-ROM | disk | FTP | other *** search
- <script>
- // LOCALIZATION STRING
- var L_INVALID_SIZE = "The size is invalid.\nMillimeters must be between 0 and 3276.7, inclusive. Inches must be between 0 and 129, inclusive.";
- </script>
-
- <script>
-
- var MMPERINCH = 25.4;
- var MAXMM = 3276.7;
- var MINMM = 0;
- var lastInchmm;
-
- function InitCustomSize()
- {
- var preferedUnit = "%1";
- var width = %2;
- var height = %3;
-
- if ( preferedUnit == "inch" )
- {
- document.layoutform.inchmm[0].checked = true;
- lastInchmm = 0;
- document.layoutform.visiblewidth.value = Math.round(width / MMPERINCH * 1000) / 1000;
- document.layoutform.visibleheight.value = Math.round(height / MMPERINCH * 1000) / 1000;
- }
- else
- {
- document.layoutform.inchmm[1].checked = true;
- lastInchmm = 1;
- document.layoutform.visiblewidth.value = width;
- document.layoutform.visibleheight.value = height;
- }
-
- document.layoutform.customwidth.value = width;
- document.layoutform.customheight.value = height;
- }
-
- function ChangeInchmm()
- {
- var oldWidth = Number( document.layoutform.customwidth.value );
- var oldHeight = Number( document.layoutform.customheight.value );
-
- if ( isNaN( oldWidth ) || ( ( oldWidth < MINMM ) || ( oldWidth > MAXMM ) ) )
- {
- alert( L_INVALID_SIZE );
-
- document.layoutform.visiblewidth.focus();
- document.layoutform.visiblewidth.select();
-
- document.layoutform.inchmm[lastInchmm].checked = true;
- return false;
- }
-
- if ( isNaN( oldHeight) || ( ( oldHeight < MINMM ) || ( oldHeight > MAXMM ) ) )
- {
- alert( L_INVALID_SIZE );
-
- document.layoutform.visibleheight.focus();
- document.layoutform.visibleheight.select();
-
- document.layoutform.inchmm[lastInchmm].checked = true;
- return false;
- }
-
- if ( lastInchmm == 0 )
- lastInchmm = 1;
- else
- lastInchmm = 0;
-
- if ( document.layoutform.inchmm[0].checked )
- {
- document.layoutform.visiblewidth.value = String( Math.round(oldWidth / MMPERINCH * 1000) / 1000 );
- document.layoutform.visibleheight.value = String( Math.round(oldHeight / MMPERINCH * 1000) / 1000 );
- }
- else
- {
- document.layoutform.visiblewidth.value = String( Math.round(oldWidth * 10) / 10 );
- document.layoutform.visibleheight.value = String( Math.round(oldHeight * 10) / 10 );
- }
- }
-
- function CheckCustomSize()
- {
- UpdateWidth();
- UpdateHeight();
-
- var isInch = document.layoutform.inchmm[0].checked;
- var width = Number( document.layoutform.customwidth.value );
- var height = Number( document.layoutform.customheight.value );
-
- // validate
- if ( isNaN( width ) || ( ( width < MINMM ) || ( width > MAXMM ) ) )
- {
- alert( L_INVALID_SIZE );
-
- document.layoutform.visiblewidth.focus();
- document.layoutform.visiblewidth.select();
-
- return false;
- }
-
- if ( isNaN( height ) || ( ( height < MINMM ) || ( height > MAXMM ) ) )
- {
- alert( L_INVALID_SIZE );
-
- document.layoutform.visibleheight.focus();
- document.layoutform.visibleheight.select();
-
- return false;
- }
-
- // ready to submit in mm
- return true;
- }
-
- function UpdateWidth()
- {
- var value = Number(document.layoutform.visiblewidth.value);
-
- if ( isNaN( value ) )
- document.layoutform.customwidth.value = document.layoutform.visiblewidth.value;
- else
- {
- if ( document.layoutform.inchmm[0].checked )
- {
- document.layoutform.customwidth.value = value * MMPERINCH;
- document.layoutform.visiblewidth.value = Math.round( document.layoutform.customwidth.value / MMPERINCH * 1000 ) / 1000;
- }
- else
- {
- document.layoutform.customwidth.value = value;
- }
- }
- }
-
- function UpdateHeight()
- {
- var value = Number(document.layoutform.visibleheight.value);
-
- if ( isNaN( value ) )
- document.layoutform.customheight.value = document.layoutform.visibleheight.value;
- else
- {
- if ( document.layoutform.inchmm[0].checked )
- {
- document.layoutform.customheight.value = value * MMPERINCH;
- document.layoutform.visibleheight.value = Math.round( document.layoutform.customheight.value / MMPERINCH * 1000 ) / 1000;
-
- }
- else
- {
- document.layoutform.customheight.value = value;
- }
- }
- }
-
- </script>
- <tr>
- <td class='list'> </td>
- <td class='list'>
- <table border=0 cellpadding=2 cellspacing=0>
- <tr>
- <td class="list" valign=middle>
- Measuring units:
- </td>
- <td class='list'>
- <table border=0 cellpadding=2 cellspacing=0>
- <tr>
- <td class="list" width=50% nowrap>
- <input type="radio" name="inchmm" value="inch" onclick="ChangeInchmm();"> inches
- </td>
- <td class="list" nowrap>
- <input type="radio" name="inchmm" value="mm" onclick="ChangeInchmm();"> millimeters
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td class='list'>
- Page width:
- </td>
- <td class='list'>
- <input type="text" name="visiblewidth" value="" size=6 onchange="UpdateWidth();">
- <input type="hidden" name="customwidth" value="">
- </td>
- </tr>
- <tr>
- <td class='list'>
- Page height:
- </td>
- <td class='list'>
- <input type="text" name="visibleheight" value="" size=6 onchange="UpdateHeight();">
- <input type="hidden" name="customheight" value="">
- </td>
- </tr>
- </table>
- </td>
- </tr>
-